package com.spring.annotation.connectDatabase;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

import javax.sql.DataSource;

/**
 * Created by wangyg on 2017/1/12.
 */
@Configuration
@ImportResource("classpath:spring-connectdatabase.xml")
public class JdbcConfig {
	@Value("${jdbc.username}")
	private String username;
	@Value("${password}")
	private String password;
	@Value("${url}")
	private String url;

	@Bean(name="myDriverManager")
	public DataSource datasource() {
		return new DriverManagerDataSource(url, username, password);
	}
}